var n = require("../../data.js"),
    o = getApp();

Page({
    data: {
        minHeight: "",
        mojiList: [],
        userInfo: {},
        hiraganaShow: !0,
        changeKANAText: "あ",
        tabnow: "seionn",
        sannbunn: !1,
        showwindow: !1,
        opacity: 1,
        itemcolor: "#000"
    },
    onLoad: function() {
        console.log("onLoad");
        var t = this;
        wx.getSystemInfo({
            success: function(n) {
                t.setData({
                    minHeight: n.windowHeight
                });
            }
        }), t.setData({
            mojiList: n.seionn,
            userInfo: getApp().globalData.userInfo
        }), o.getUserInfo(function(n) {
            t.setData({
                userInfo: n
            }), console.log(n);
        });
    },
    changeKANA: function(n) {
        var o = this.data.hiraganaShow;
        this.setData({
            hiraganaShow: !o,
            tabnow: this.data.tabnow
        }), o ? this.setData({
            changeKANAText: "ア"
        }) : this.setData({
            changeKANAText: "あ"
        });
    },
    toSEIONN: function() {
        this.setData({
            mojiList: n.seionn,
            tabnow: "seionn",
            sannbunn: !1
        });
    },
    toDAKUONN: function() {
        this.setData({
            mojiList: n.dakuonn,
            tabnow: "dakuonn",
            sannbunn: !1,
            showwindow: !1,
            opacity: 1
        });
    },
    toYOUONN: function() {
        this.setData({
            mojiList: n.youonn,
            tabnow: "youonn",
            sannbunn: !0,
            showwindow: !1,
            opacity: 1
        });
    },
    toCustomer: function() {
        wx.navigateTo({
            url: '../apply/apply'
        })
    },
    itemonclick: function(n) {
        var o = n.currentTarget.dataset.gana,
            t = n.currentTarget.dataset.roomaji,
            a = n.currentTarget.dataset.index + 1,
            e = this.data.hiraganaShow,
            i = wx.createInnerAudioContext(),
            s = this.data.tabnow,
            c = "pian";
        e && (c = "ping");
        var r = n.currentTarget.dataset.duyin;
        if (void 0 != r) {
            console.log(o + "  " + t + "  读音:" + r + "  index=" + a);
            if (s == "seionn" || "kana") {
                var u = "https://res.hjfile.cn/pt/m/jp/50yin/img/gif/" + c + "/" + c + "_gif_" + t + a + ".gif",
                    h = "https://res.hjfile.cn/pt/m/jp/50yin/audio/" + encodeURIComponent(r) + ".mp3";
                console.log(h), console.log(u), console.log(s);
            } else {
                var h = "https://res.hjfile.cn/pt/m/jp/50yin/audio/" + encodeURIComponent(r) + ".mp3";
                console.log(h), console.log(u), console.log(s);
            }
            console.log(e)
            var g = !1;
            "seionn" == s || "kana" == s ? (g = !0, i.loop = !1, this.setData({
                itemcolor: "#fff",
                itempic: u,
                showwindow: g,
                opacity: 1
            })) : (g = !1, i.loop = !1, this.setData({
                itemcolor: "#fff",
                showwindow: g,
                opacity: 1
            })), i.autoplay = !0, i.obeyMuteSwitch = !0, i.src = h, i.onPlay(function() {
                console.log("开始播放");
            }), i.onError(function(n) {
                console.log(n.errMsg), console.log(n.errCode);
            }), i.onEnded(function(n) {
                i.destroy();
            });
        }
    },
    close: function(n) {
        this.setData({
            showwindow: !1,
            opacity: 1
        });
    },
    onShareAppMessage: function() {
        return {
            title: "跟你说，学日语我就没怕过，不懂找沃趣",
            path: "/pages/gojuuonn/gojuuonn"
        };
    }
});